<?php 
$sql =	"SELECT
			  c.page_id,
			  d.title,
			  d.description,
			  d.meta_key,
			  d.meta_description	
		  FROM
			  pages AS c,
			  page_description AS d
		  WHERE
		  
			  c.page_id = d.page_id
			  AND
			  d.lang_id = '".$_SESSION['lang_id']."'
			  AND
			  c.sef_url = '".$sef_url."' 
			  AND c.published
		  ";
$result = query($sql);
$row = mysql_fetch_object($result);

head(sth($row->title),sth($row->meta_description));

$coor = explode(",", $row->meta_key)

?>


		<div id="content" style="padding-bottom:0"><div id="dealers">
			
			<h1><?=$row->title?></h1>
			
			<div class="left narrow">
				
				<h4><?=__Contact_form?></h4>
				
				<form id="contact-form">
				<?=__name?><br>
				<input type="text" name="name" value=""><br>
				
				<?=__E_mail?><br>
				<input type="text" name="email" value=""><br>
				
				<?=__Subject?><br>
				<input type="text" name="subject" value=""><br>
				
				<?=__Text?><br>
				<textarea id="conmess" rows="6"  name="message"></textarea>
				<br>
				<div class="message blue"></div>
				<a class="button" onclick="send_contact_form();"><?=__Send?></a>
				
				</form>
				
			</div>
			
			<div class="right wide">
				<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
				<script type="text/javascript" src="<?=HTML_BASE?>js/contacts_map.js"></script>
				<div id="map">
				</div>
				<script type="text/javascript">
					initialize("<?=$coor[0]?>","<?=$coor[1]?>");
				</script>
			</div>
			
			<div class="right wide">						
				
				<h4><?=__Get_in_touch?></h4>
						
				 <?=stripslashes($row->description)?>
				<h4><?=__Social_contacts?></h4>
                
			</div>
			
		
			<div id="dealerspop">
			
			<div class="full left">
            
            <?php
            $sql =	"SELECT
			  d.title,
			  d.description	
		  FROM
			  pages AS c,
			  page_description AS d
		  WHERE
			  c.page_id = d.page_id
			  AND
			  d.lang_id = '".$_SESSION['lang_id']."'
			  AND
			  c.sef_url = 'dealers' 
			  AND c.published
		  ";
			$result = query($sql);
			$row = mysql_fetch_object($result);
			
			?>
				
				<h3><?=$row->title?></h3>
				
				 <?=stripslashes($row->description)?>
			</div>
			
			<div class="full left" style="margin-top:30px">
			<?=__CONFIDENTIAL_APPLICATION?>
			
			<br><br>

			
			<form id="partner-reg">
			<table width="70%">
				<tr style="width:50%">
					<td>
						<?=__Name_of_representative?><br>
						<input name="representative" type="text" value="">
					</td>
					<td>
						<?=__Title_Position?><br>
						<input name="position" type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__Phone?><br>
						<input name="phone" type="text" value="">
					</td>
					<td>
						<?=__E_mail?><br>
						<input name="email" type="text" value="">
					</td>
				</tr>
			</table>
			
			<br><br>
			
			<table width="70%">
				<tr style="width:50%">
					<td>
						<?=__Company_Name?><br>
						<input name="company" type="text" value="">
					</td>
					<td>
						<?=__NIPC?><br>
						<input name="nipc" type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__Adress?><br>
						<input name="adress" type="text" value="">
					</td>
					<td>
						<?=__Location?><br>
						<input name="location" type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__Postcode?><br>
						<input name="postcode" type="text" value="">
					</td>
					<td>
						<?=__District?><br>
						<input name="district" type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__Country?><br>
						<input name="country" type="text" value="">
					</td>
					<td>
						<?=__Phone?><br>
						<input name="cphone" type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__E_mail?><br>
						<input name="cemail" type="text" value="">
					</td>
					<td>
						<?=__Confirm_Email?><br>
						<input name="confirm"  type="text" value="">
					</td>
				</tr>
				<tr>
					<td>
						<?=__Fax?><br>
						<input name="fax" type="text" value="">
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
			</table>
			
			<table width="70%">
				<tr style="width:50%">
					<td>
						<br><?=__Park_in_operation?>:       
						<label>
						<input type="radio" name="park_in_operation" value="<?=__Yes?>" >
						<?=__Yes?></label>
						<label>
						<input type="radio" name="park_in_operation" checked="checked" value="<?=__No?>">
						<?=__No?></label>
						<br><br>
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
				<tr>
					<td>
						<?=__Parking_areas?>:
						<label>
						<input type="radio" name="parking_areas" value="<?=__Lisbon?>">
						<?=__Lisbon?></label>
						<label>
						<input type="radio" name="parking_areas" value="<?=__Port?>">
						<?=__Port?></label>
						<label>
						<input type="radio" name="parking_areas" checked="checked" value="">
						<?=__Other?>:</label>
						
						<input name="other" style="width:100px;" type="text" value=""><br><br>
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
				<tr>
					<td>
						<?=__Distribution_value?>:<br>
						<input name="ditribution" type="text" value="eg. 15min./€0.20, 30min./€0.40..."
						onblur="if(this.value=='') this.value='eg. 15min./€0.20, 30min./€0.40...';" 
						onfocus="if(this.value=='eg. 15min./€0.20, 30min./€0.40...') this.value='';" >
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
				<tr>
					<td>
						<?=__Parking?>:<br>
						<input name="parking" type="text" value="<?=__nr_places?>"
						onblur="if(this.value=='') this.value='<?=__nr_places?>';" 
						onfocus="if(this.value=='<?=__nr_places?>') this.value='';" >
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
				<tr>
					<td>
						<?=__Remarks?>:<br>
						<textarea id="partmess"  rows="6" name="message"></textarea>
					</td>
					<td>&nbsp;
						
					</td>
				</tr>
				
			</table>
			
			<br><br>
			<label>
			<input name="iagree" type="checkbox" value="1">
			<?=__I_agree_to_the?> <a target="_blank" href="/terms-of-use"><?=__Terms_and_Conditions?></a>
			</label>
			
			<br>
            <div class="message blue"></div>
            <br>
			<a class="button" onclick="send_partners(); return false;"><?=__Send?></a>
			
			<a id="dealersClose" class="button"><?=__Close?></a>
			
			</form>
			</div>
			
			</div>
		
		</div></div><!--#content-->
        
        <script type="text/javascript">
		
		function IsEmail(email) {
			  var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			  return regex.test(email);
			}
		
		
		function send_contact_form()
		{
			$('#contact-form input,select,textarea').removeClass('redborder');
			var error = '';
			$( '#contact-form input').each(function() {
				if(!$( this ).val()){
					 $( this ).addClass('redborder');
					 error += $( this ).attr('name')+',';
				}else{
					
					if($( this ).attr('name') == 'email'  && !IsEmail($( this ).val()) )
					{
						 error += $( this ).attr('name')+',';
						 $( this ).addClass('redborder');
					}
						
				}
			});
			
			
			if(!$("textarea#conmess").val())
			{
				 $("textarea#conmess").addClass('redborder');
				error += 'message';
			}
			
			if(!error)
			{
				
				var json = '{'
				$( '#contact-form input').each(function() {
					
					json += '"'+$( this ).attr('name')+'":"'+$( this ).val()+'",';
				});
								
				json += '"message":"'+$("textarea#conmess").val()+'"'
				
				json += '}';
				
				json =JSON.stringify(json);
				
				
				 $.ajax({
							type: 'POST',
							url:'<?=HTML_BASE?>send.php',
							data: 'type=contact&alldata=' +json,
							success: function(msg){
										$('#contact-form .message').html('<?=__Message_sent?>');
										$('#contact-form .message').slideDown().delay(4000).slideUp();	
									},
							error: function(msg){
										$('#contact-form .message').html('Error:'+ msg);
										$('#contact-form .message').slideDown().delay(4000).slideUp();
									}
						});
				
				
				$('#contact-form').find("input[type=text], textarea").val("");
				
			}
		}
		
		
		function send_partners()
		{
			$('#partner-reg input,select,textarea').removeClass('redborder');
			var error = '';
			$( '#partner-reg input').each(function() {
				
				if($( this ).attr('name') != 'parking_areas'  && $( this ).attr('name') != 'park_in_operation' && $( this ).attr('name') != 'other')
				{
					if(!$( this ).val()){
						 $( this ).addClass('redborder');
						 error += $( this ).attr('name')+',';
					}else{
						if(($( this ).attr('name') == 'email' || $( this ).attr('name') == 'cemail') && !IsEmail($( this ).val()) )
						{
							 error += $( this ).attr('name')+',';
							 $( this ).addClass('redborder');
						}
						
							
					}
				}
			});
			
			
			if($("[name='parking_areas']:checked").val())
			{
				 $("[name='other']").removeClass('redborder');
			}
			
			if($("[name='confirm']").val() != $("[name='cemail']").val())
			{ 
				$("[name='confirm']").addClass('redborder');
				error += 'confirm,';
			}
			 
			if(!$("[name='iagree']").attr("checked"))
			{
				 $("[name='iagree']").addClass('redborder');
				 error += 'iagree,';
			}
			
			if(!$("textarea#partmess").val())
			{
				 $("[name='message']").addClass('redborder');
				 error += 'message,';
			}
			
			
			if(!error)
			{
				var json = '{'
				$( '#partner-reg input').each(function() {
					var nm = $( this ).attr('name');
					if(nm != 'parking_areas'  && nm != 'other' && nm != 'iagree' && nm != 'park_in_operation')
					{
						json += '"'+$( this ).attr('name')+'":"'+$( this ).val()+'",'
					}
				
				});
				
				json += '"park_in_operation":"'+$("[name='park_in_operation']:checked").val()+'",';
				
				if(!$("[name='parking_areas']:checked").val())
				{
					json += '"areas":"'+$("[name='other']").val()+'",';
				}else{
					json += '"areas":"'+$("[name='parking_areas']:checked").val()+'",';
				}
				
				json += '"message":"'+$("textarea#partmess").val()+'"';
				
				json += '}';
								
				$('#partner-reg .message').html(json);
				json =JSON.stringify(json);
				
				$.ajax({
							type: 'POST',
							url:'<?=HTML_BASE?>send.php',
							data: 'type=partner&alldata=' +json,
							success: function(msg){
									$('#partner-reg .message').html('<?=__Message_sent?>');
									$('#partner-reg .message').slideDown().delay(4000).slideUp();	
								},
								error: function(msg){
									$('#partner-reg .message').html('Error:'+ msg);
									$('#partner-reg .message').slideDown().delay(4000).slideUp();	
								}
						});
						
				$('#partner-reg').find("input[type=text], textarea").val("");
			}
		
		}
		
		</script>
       
	
<?php

foot();
?>